package com.dys.myvar;

/**
 * @className: com.dys.myvar.VarTest
 * @description: 变量
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/06/11 下午11:09
 */
public class VarTest {
    public static void main(String[] args) {
        calculatedValue();
    }

    /**
     * 变量的声明和使用
     */
    public static void declarationOfVariable() {
        // 1.变量的声明
        int age;
        // 2.变量的赋值
        age = 20;
        age = age + 5;
        // 3.变量的使用
        System.out.println(age);
    }

    public static void declarationOfVariable2() {
        // 1.变量的声明和赋值：声明一个变量,变量名字叫num1,为变量赋值为10
        int num1 = 10;
        int num2 = 10;
        int sum = num1 + num2;
        System.out.println(sum);
    }

    public static void calculatedValue() {
        // 声明一个变量,变量名字叫num1,为变量赋值为10
        int num1 = 10;
        int num2 = 20;
        num1 = num2;
        num2 = num2 + 10;
        num1 = num2 - 10;
        num2 = num1;
        System.out.println("num1 = " + num1);
        System.out.println("num2 = " + num2);
    }
}
